package Vis;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;

import bodyPosition.PositionStorage;

/**
 * Store position data of a particular user
 * @author norrielm
 *
 */
public class User extends JPanel{
	
	int id;
	float[][] bodyPos = null; //24 body positions in 3d space
	PositionStorage positions; 
	
	enum BodyParts{
		HEAD, 			NECK, 			TORSO, 			WAIST,  
		LEFT_COLLAR, 	LEFT_SHOULDER, 	LEFT_ELBOW, 	LEFT_WRIST,   
		LEFT_HAND, 		LEFT_FINGERTIP, RIGHT_COLLAR, 	RIGHT_SHOULDER,   
		RIGHT_ELBOW, 	RIGHT_WRIST, 	RIGHT_HAND, 	RIGHT_FINGERTIP,   
		LEFT_HIP, 		LEFT_KNEE, 		LEFT_ANKLE, 	LEFT_FOOT,   
		RIGHT_HIP, 		RIGHT_KNEE, 	RIGHT_ANKLE, 	RIGHT_FOOT  
	};
	
	public User(int id){
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		this.add(new JLabel(String.format("User id: %s", id)));
		this.id = id;
		
		bodyPos = new float[24][3];
		
		/*for(int i=0; i<24; i++){
			this.add(new JLabel(String.format("%s: (%f,%f,%f)", BodyParts.values()[i].name(), 
										bodyPos[i][0],bodyPos[i][1],bodyPos[i][2])));
		}*/
		positions = new PositionStorage();
		
		validate();
		
	}
	
	public PositionStorage getPositionStorage(){
		return positions;
	}
	
	public int getID(){
		return id;
	}
	
	public boolean equals(User u){
		if(u==null || u.getClass() != this.getClass())
			return false;
		return u.getID() == id;
	}
	
	public void setPos(int part, float x, float y, float z){
		bodyPos[part][0] = x;
		bodyPos[part][0] = y;
		bodyPos[part][0] = z;
	}
	
}
